/**
 * 创建 Virtual DOM
 * @param {string} type 类型
 * @param {object | null} props 属性
 * @param  {createElement[]} children 子元素
 * @return {object} Virtual DOM
 */
export default function createElement (type, props, ...children) {
  const childrenElement = [].concat(...children).reduce((result, child) => {
    // 过滤不显示的节点
    if ( child !== false && child !== true && child !== null) {
      if (child instanceof Object) {
        result.push(child)
      } else {
        result.push(createElement('text', {textContent: child}))
      }
    }
    return result
  }, [])
  return {
    type,
    props: Object.assign({children: childrenElement}, props),
    // children: childrenElement
  }
}